package cn.iocoder.yudao.module.polling.dal.mysql.pollingtask;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.polling.controller.admin.pollingtask.vo.PollingTaskExportReqVO;
import cn.iocoder.yudao.module.polling.controller.admin.pollingtask.vo.PollingTaskPageReqVO;
import cn.iocoder.yudao.module.polling.dal.dataobject.pollingtask.PollingTaskDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 巡检任务 Mapper
 *
 * @author 左达成
 */
@Mapper
public interface PollingTaskMapper extends BaseMapperX<PollingTaskDO> {

    default PageResult<PollingTaskDO> selectPage(PollingTaskPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PollingTaskDO>()
                .eqIfPresent(PollingTaskDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(PollingTaskDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(PollingTaskDO::getUpdater, reqVO.getUpdater())
                .eqIfPresent(PollingTaskDO::getTaskCode, reqVO.getTaskCode())
                .eqIfPresent(PollingTaskDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(PollingTaskDO::getTaskState, reqVO.getTaskState())
                .betweenIfPresent(PollingTaskDO::getTaskStartTime, reqVO.getTaskStartTime())
                .betweenIfPresent(PollingTaskDO::getTaskEndTime, reqVO.getTaskEndTime())
                .orderByDesc(PollingTaskDO::getId));
    }

    default List<PollingTaskDO> selectList(PollingTaskExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PollingTaskDO>()
                .eqIfPresent(PollingTaskDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(PollingTaskDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(PollingTaskDO::getUpdater, reqVO.getUpdater())
                .eqIfPresent(PollingTaskDO::getTaskCode, reqVO.getTaskCode())
                .eqIfPresent(PollingTaskDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(PollingTaskDO::getTaskState, reqVO.getTaskState())
                .betweenIfPresent(PollingTaskDO::getTaskStartTime, reqVO.getTaskStartTime())
                .betweenIfPresent(PollingTaskDO::getTaskEndTime, reqVO.getTaskEndTime())
                .orderByDesc(PollingTaskDO::getId));
    }

}
